<template>
  <div class="contentWrapper wpx1200" id="contentWrapper">
    <el-card class="box-card mt20">
		  <div slot="header" class="clearfix">
		    <span>检测记录</span>
		    <!--<span class="floatr lan cursor">下载</span>-->
		  </div>
		  <div class="clearFix">
		  	<el-table
		      :data="tableData"
	        v-loading="loading"
		      style="width: 100%">
		      <el-table-column label="序号" width="100" type="index">
					  
					</el-table-column>
		      <el-table-column
		        label="详细信息"
		        width="480">
		        <template slot-scope="scope">
		        	<div>
		        		{{scope.row.taskName || scope.row.taskId}}
		        	</div>
		        	<!--<p class="clearFix">
		        		<div class="floatl w10 scbold">
		        			检测内容：
		        		</div>
		        		<div class="floatl w90">
		        			{{scope.row.content}}
		        		</div>
		        	</p>
		        	<p class="clearFix">
		        		<div class="floatl w10 scbold">
		        			关键词：
		        		</div>
		        		<div class="floatl w90">
		        			{{scope.row.wordList}}
		        		</div>
		        	</p>-->
					   		
					  </template>
		      </el-table-column>
		      <el-table-column
		        label="检测类型"
		        width="400">
		        <template slot-scope="scope">
					   		<span v-show="scope.row.taskType ==1">图片</span>
					   		<span v-show="scope.row.taskType ==2">文稿</span>
					   		<span v-show="scope.row.taskType ==3">网址</span>
					   		<span v-show="scope.row.taskType ==4">店铺</span>
					  </template>
		      </el-table-column>
		      <el-table-column label="操作">
			      <template slot-scope="scope">
			        <el-button  type="primary"
			          @click="handleEdit(scope.row.taskId,scope.row.taskType,scope.row.wordList,scope.row,scope.row.taskName)">查看</el-button>
			          <el-button  type="danger"
			          @click="deleteItem(scope.row.taskId)">删除</el-button>
			      </template>
			    </el-table-column>
		    </el-table>
		  </div>
		  <div class="text_center">
		  	<el-pagination
				  background
				  @current-change="handleCurrentChange"
				  layout="prev, pager, next"
				  :page-size="10"
				  :total="totalCount">
				</el-pagination>
		  </div>
		  
		</el-card>
  </div>
</template>

<script>
import MsgBus from '@/components/bus.js';
import API from "@/api"
export default {
  name: 'setting',
  data () {
    return {
    	list: [],
    	 tableData: [],
    	 loading: true,
    	 totalCount:270,
    	 pageno:1,
    }
  },
  mounted: function () {
  	setMinHeight("contentWrapper")
  	this.getList()
  		$(window).resize(function() {
		  setMinHeight("contentWrapper")
		});
  },
   methods: {
   	deleteItem(id){
//   			  	console.error(id)
	  	this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'error',
          lockScroll: false
        }).then(() => {
        	var info = {
        		token: API.header.getCookie("token"),
        		id:id
        	}
        	API.record.deleteRecord(info).then(({data}) => {
			       if(data.code=='0'){
									this.$message({
				            type: 'success',
				            message: '删除成功!'
				          });
				          this.getList()
			       }else{
								this.$message.error(data.msg);
			       }
		      })
        }).catch(() => {});
   	},
	  getList(){
	  	API.record.getList(API.header.getCookie("token"),this.pageno).then(({data}) => {
	  			this.loading = false
	       if(data.code=='0'){
						this.tableData = data.data.list;
						this.totalCount = data.data.totalCount
	       }else{
						this.$message.error(data.msg);
	       }
      })
	  },
	  handleCurrentChange: function(val) {
  		this.pageno = val;
  		this.getList();
//      	console.error(this.pageno);
  	},
	  handleEdit(id,type,wordList,item,taskName){
	  	if(type == 1){
//	  		this.$router.push({
//				      path: `/imgResultList?${id}`,
//				   })
				var taskName = encodeURIComponent(taskName)
				this.$router.push({path: '/imgResultList', query: {id:id,taskName:taskName}})
	  		
	  		sessionStorage.setItem("imgWordList",wordList)
	  	}else if(type == 2){
//	  		console.error(item.content)
	  		sessionStorage.setItem("content",item.content)
	  		sessionStorage.setItem("contentwordList",wordList)
	  		this.$router.push({
				      path: `/textCheck?#id`,
				   })
	  	}else if(type == 3){
	  		sessionStorage.setItem("urlWordList",wordList)
	  		this.$router.push({
				      path: `/recordDetail?${id}`,
				   })
	  	}
	  	
	  },
	  toDetail(data) {
	    sessionStorage.setItem("setdata",JSON.stringify(data))
	  	this.$router.push({
	      name: 'settingDetail',
	    })
	  }
	}
  
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
	#app {
		/*text-align: left;*/
	}
	.smallCard {
		 width: 260px;
    margin: 13px;
    float: left;

	}
	div.jiu {
		height: 105px;
	}
	.add{
		font-size: 70px;
    text-align: center;
    line-height: 105px;
    cursor: pointer;
	}
	.add span {
	    position: relative;
    	top: -10px;
	}
	.el-icon-edit {
		margin-left: 160px;
		cursor: pointer;
	}
	.el-icon-edit:before {
    content: "\E61C";
    color: #000;
	}
</style>
